package com.hezhi.project.module.recipient.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hezhi.common.utils.StringUtils;
import com.hezhi.project.module.recipient.mapper.RecipientMapper;
import com.hezhi.project.module.recipient.domain.Recipient;
import com.hezhi.project.module.recipient.service.IRecipientService;
import com.hezhi.common.support.Convert;

/**
 * 通知消息接收 服务层实现
 * 
 * @author hezhi
 * @date 2018-08-13
 */
@Service
public class RecipientServiceImpl implements IRecipientService 
{
	@Autowired
	private RecipientMapper recipientMapper;

	/**
     * 查询通知消息接收信息
     * 
     * @param noticeId 通知消息接收ID
     * @return 通知消息接收信息
     */
    @Override
	public Recipient selectRecipientById(Integer noticeId)
	{
	    return recipientMapper.selectRecipientById(noticeId);
	}
	
	/**
     * 查询通知消息接收列表
     * 
     * @param recipient 通知消息接收信息
     * @return 通知消息接收集合
     */
	@Override
	public List<Recipient> selectRecipientList(Recipient recipient)
	{
	    return recipientMapper.selectRecipientList(recipient);
	}
	
    /**
     * 新增通知消息接收
     * 
     * @param recipient 通知消息接收信息
     * @return 结果
     */
	@Override
	public int insertRecipient(Recipient recipient)
	{
	    return recipientMapper.insertRecipient(recipient);
	}
	
	/**
     * 修改通知消息接收
     * 
     * @param recipient 通知消息接收信息
     * @return 结果
     */
	@Override
	public int updateRecipient(Recipient recipient)
	{
	    return recipientMapper.updateRecipient(recipient);
	}
	
	/**
     * 保存通知消息接收
     * 
     * @param recipient 通知消息接收信息
     * @return 结果
     */
	@Override
	public int saveRecipient(Recipient recipient)
	{
	    Integer noticeId = recipient.getNoticeId();
		int rows = 0;
		if (StringUtils.isNotNull(noticeId))
        {
		    rows = recipientMapper.updateRecipient(recipient);
		}
		else
        {
		    rows = recipientMapper.insertRecipient(recipient);
		}
		return rows;
	}
	
	/**
     * 删除通知消息接收对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteRecipientByIds(String ids)
	{
		return recipientMapper.deleteRecipientByIds(Convert.toIntArray(ids));
	}
	
}
